package com.ericsson.enap.modules.ossalarm.task.ims;

import com.ericsson.common.quartz.task.ManualTask;
import com.ericsson.common.util.DateUtils;
import com.ericsson.enap.modules.ossalarm.mapper.OssAlarmMapper;
import com.ericsson.enap.modules.sys.entity.EpcDict;
import com.ericsson.enap.modules.sys.service.EpcDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * IMS ENM告警 过期数据清理
 */
@Component
public class OssFromNMSAlarmClearTask implements ManualTask {
    @Autowired
    private EpcDictService epcDictService;
    @Autowired
    private OssAlarmMapper ossAlarmMapper;
    @Override
    public void execute() {
        EpcDict epcDict=new EpcDict();
        epcDict.setKeyName("IMSENMALARMTIME");
        epcDict= epcDictService.selectEpcDict(epcDict);
        if(null!=epcDict&&!"".equals(epcDict.getKeyValue())) {
            Date now = new Date();
            String deleteTime = DateUtils.getStatisTime(Integer.parseInt(epcDict.getKeyValue())*1440,now,"yyyy-MM-dd HH:mm:00");
            System.out.println("deleteTime-------------------------------:"+deleteTime);
            ossAlarmMapper.deleteData(deleteTime);
            System.out.println("end-------------------------------");
        }
    }
}
